class CountFormatUtils {
  /// 格式化计数字符串：
  /// 0-999 显示全量；1000-9999 显示 1k-9.9k；10000-99999999 显示 1w-9999.9w
  static String formatCount(int count) {
    if (count < 1000) return count.toString();

    if (count < 10000) {
      final val = count / 1000;
      final text = val.toStringAsFixed(1);
      final trimmed =
          text.endsWith('.0') ? text.substring(0, text.length - 2) : text;
      return '${trimmed}k';
    }

    final val = count / 10000;
    final text = val.toStringAsFixed(1);
    final trimmed =
        text.endsWith('.0') ? text.substring(0, text.length - 2) : text;
    return '${trimmed}w';
  }
}
